package com.ruoyi.web.controller.owner;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PropertyNoticeRead;
import com.ruoyi.system.service.IPropertyNoticeReadService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 通知阅读记录Controller
 * 
 * @author ruoyi
 * @date 2025-10-27
 */
@RestController
@RequestMapping("/system/read")
public class PropertyNoticeReadController extends BaseController
{
    @Autowired
    private IPropertyNoticeReadService propertyNoticeReadService;

    /**
     * 查询通知阅读记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:read:list')")
    @GetMapping("/list")
    public TableDataInfo list(PropertyNoticeRead propertyNoticeRead)
    {
        startPage();
        List<PropertyNoticeRead> list = propertyNoticeReadService.selectPropertyNoticeReadList(propertyNoticeRead);
        return getDataTable(list);
    }

    /**
     * 导出通知阅读记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:read:export')")
    @Log(title = "通知阅读记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PropertyNoticeRead propertyNoticeRead)
    {
        List<PropertyNoticeRead> list = propertyNoticeReadService.selectPropertyNoticeReadList(propertyNoticeRead);
        ExcelUtil<PropertyNoticeRead> util = new ExcelUtil<PropertyNoticeRead>(PropertyNoticeRead.class);
        util.exportExcel(response, list, "通知阅读记录数据");
    }

    /**
     * 获取通知阅读记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:read:query')")
    @GetMapping(value = "/{readId}")
    public AjaxResult getInfo(@PathVariable("readId") Long readId)
    {
        return success(propertyNoticeReadService.selectPropertyNoticeReadByReadId(readId));
    }

    /**
     * 新增通知阅读记录
     */
    @PreAuthorize("@ss.hasPermi('system:read:add')")
    @Log(title = "通知阅读记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PropertyNoticeRead propertyNoticeRead)
    {
        return toAjax(propertyNoticeReadService.insertPropertyNoticeRead(propertyNoticeRead));
    }

    /**
     * 修改通知阅读记录
     */
    @PreAuthorize("@ss.hasPermi('system:read:edit')")
    @Log(title = "通知阅读记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PropertyNoticeRead propertyNoticeRead)
    {
        return toAjax(propertyNoticeReadService.updatePropertyNoticeRead(propertyNoticeRead));
    }

    /**
     * 删除通知阅读记录
     */
    @PreAuthorize("@ss.hasPermi('system:read:remove')")
    @Log(title = "通知阅读记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{readIds}")
    public AjaxResult remove(@PathVariable Long[] readIds)
    {
        return toAjax(propertyNoticeReadService.deletePropertyNoticeReadByReadIds(readIds));
    }
}
